package com.example.as_sum.activity;

import android.content.Intent;
import android.os.Handler;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.example.as_sum.R;
import com.example.as_sum.application.AppApplication;
import com.example.as_sum.application.Constant;
import com.example.as_sum.util.Log;
import com.example.as_sum.util.SharePerferenceUtil;

import java.util.List;

public class LoginActivity extends BaseActivity{
    private TextView login_btn;
    private EditText ed_num;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initTitle("登录");
        AppApplication.aContext.getAllActivity();
    }

    @Override
    public int getContentId() {
        return R.layout.activity_login;
    }

    @Override
    public void initView() {
        login_btn=(TextView)this.findViewById(R.id.login_btn);
        ed_num=(EditText)this.findViewById(R.id.login_ed_paw);
    }

    @Override
    public void addListener() {
        login_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String phone=ed_num.getText().toString();
                if(phone.length()!=11){
                    showShortMsg("手机号不合法");
                    return;
                }
                SharePerferenceUtil.putMobile(LoginActivity.this, phone);

                Intent intent=new Intent();
                intent.setAction(Constant.ACTION_LOGIN_SC);
                sendBroadcast(intent);
                Log.e("----登陆成功---->", "发送广播");

                finish();
            }
        });
    }

    @Override
    public void loadData() {

    }

    @Override
    public Handler getHandler() {
        return null;
    }
}
